package com.t235.gc.biz.service.impl;

import com.t235.gc.entity.Replenishment;
import com.t235.gc.dao.ReplenishmentDao;
import com.t235.gc.biz.service.ReplenishmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 补货员/运维人员表(Replenishment)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:38
 */
@Service("replenishmentService")
public class ReplenishmentServiceImpl implements ReplenishmentService {
    @Resource
    private ReplenishmentDao replenishmentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param replenishmentid 主键
     * @return 实例对象
     */
    @Override
    public Replenishment queryById(Long replenishmentid) {
        return this.replenishmentDao.queryById(replenishmentid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Replenishment> queryAllByLimit(int offset, int limit) {
        return this.replenishmentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param replenishment 实例对象
     * @return 实例对象
     */
    @Override
    public Replenishment insert(Replenishment replenishment) {
        this.replenishmentDao.insert(replenishment);
        return replenishment;
    }

    /**
     * 修改数据
     *
     * @param replenishment 实例对象
     * @return 实例对象
     */
    @Override
    public Replenishment update(Replenishment replenishment) {
        this.replenishmentDao.update(replenishment);
        return this.queryById(replenishment.getReplenishmentid());
    }

    /**
     * 通过主键删除数据
     *
     * @param replenishmentid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long replenishmentid) {
        return this.replenishmentDao.deleteById(replenishmentid) > 0;
    }
}
